package org.kangjia;

import org.apache.poi.ss.usermodel.Workbook;
import org.kangjia.exportFile.ExportExcel;
import org.kangjia.extend.dynamicFields.FieldList;
import org.kangjia.extend.styles.Customize;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

public class ExportBuild<T> {

    private Class<T> clazz;

    private String sheetName;

    private List<T> list;

    private String fileName;

    private Customize customize;

    private FieldList fieldList;

    public class Build{

        public Workbook execute(){
            return new ExportExcel<T>(clazz,list,sheetName,fileName,customize,fieldList).execute();
        }

        public void execute(HttpServletResponse response){
            new ExportExcel<T>(clazz,list,sheetName,fileName,customize,fieldList).execute(response);
        }

        public void execute(String outPath){
            new ExportExcel<T>(clazz,list,sheetName,fileName,customize,fieldList).execute(outPath);
        }
    }

    public ExportBuild() {}

    public ExportBuild(Class<T> clazz, String sheetName) {
        this.clazz = clazz;
        this.sheetName = sheetName;
    }

    public ExportBuild<T> setClazz(Class<T> clazz) {
        this.clazz = clazz;
        return this;
    }

    public ExportBuild<T> setSheetName(String sheetName) {
        this.sheetName = sheetName;
        return this;
    }

    public ExportBuild<T> setList(List<T> list) {
        this.list = list;
        return this;
    }

    public ExportBuild<T> setFileName(String fileName) {
        this.fileName = fileName;
        return this;
    }

    public ExportBuild<T> setCustomize(Customize customize) {
        this.customize = customize;
        return this;
    }

    public ExportBuild<T> setFieldList(FieldList fieldList) {
        this.fieldList = fieldList;
        return this;
    }

    public Build Build(){
        return this.new Build();
    }
}

